package com.sdruixinggroup.mondayb2b.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.sdruixinggroup.mondayb2b.R;
import com.sdruixinggroup.mondayb2b.models.Collect;

/**
 * Created by 00029935 on 2017/11/17.
 */

public class MineShopsAdapter extends QuickAdapter<Collect.CollectBean.DataBean.MerchantBean> {
    private Context context;
    private OnCancleCollectListener onCancleCollectListener;
    public MineShopsAdapter(Context context) {
        this.context = context;
    }

    @Override
    public int getLayoutID(int viewType) {
        return R.layout.mine_shops_adapter_item;
    }

    @Override
    public void convert(VH holder, final Collect.CollectBean.DataBean.MerchantBean itemData,final int position) {
        ImageView ivPic =holder.getView(R.id.iv_pic);
        Glide.with(context).load(itemData.getThumb()).error(R.mipmap.collect_merchandise).into(ivPic);

        TextView tvMessage = holder.getView(R.id.tv_message);
        tvMessage.setText(itemData.getName());

        TextView tvPhone = holder.getView(R.id.tv_phone);
        tvPhone.setText(itemData.getShopkeeper() +" "+itemData.getPhone());

        TextView tvCanceCollect = holder.getView(R.id.tv_cancel_collect);
        tvCanceCollect.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(null != onCancleCollectListener){
                    onCancleCollectListener.listener(itemData,position);
                }
            }
        });
    }

    public interface OnCancleCollectListener{
        void listener( Collect.CollectBean.DataBean.MerchantBean itemData, int position);
    }

    public void setOnCancleCollectListener(OnCancleCollectListener onCancleCollectListener) {
        this.onCancleCollectListener = onCancleCollectListener;
    }
}
